package com.dux.spbtservice.aop.perm;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.context.HttpRequestResponseHolder;
import org.springframework.stereotype.Component;

import java.util.Collection;

/**
 * Title: PermAop <br>
 * Description: PermAop <br>
 * Date: 2018年10月24日
 *
 * @author 王东旭
 * @version 1.0.0
 * @since jdk8
 */
@Aspect
@Component
public class PermAspect {

    @Before("execution(* com.dux.spbtservice.web..*.*(..)) && @annotation(perm)")
    public void perm(Permission perm){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
        authorities.stream().
        System.out.println(perm);
    }

}
